package com.moli.iov.base.model;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moli.iov.base.model.po.VehicleBase;
import java.util.List;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;


/**
 * 封装查询条件
 *
 * @author whl
 */
public class VehicleBaseParam {

  private QueryWrapper<VehicleBase> queryWrapper;

  public VehicleBaseParam() {
    queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("is_delete", 0);
//    queryWrapper.eq("authorized_status", 1);
  }

  public QueryWrapper<VehicleBase> get() {
    return queryWrapper;
  }

  public VehicleBaseParam queryEqLicense(String license) {
    if (!StringUtils.isEmpty(license)) {
      queryWrapper.eq("license", license);
    }
    return this;
  }

  public VehicleBaseParam queryEqAuthorizedStatus(Integer authorizedStatus) {
    if (authorizedStatus!=null) {
      queryWrapper.eq("authorized_status", authorizedStatus);
    }
    return this;
  }

  public VehicleBaseParam queryEqVin(String vin) {
    if (!StringUtils.isEmpty(vin)) {
      queryWrapper.eq("vin", vin);
    }
    return this;
  }
  public VehicleBaseParam queryLikeLeftVin(String vin) {
    if (!StringUtils.isEmpty(vin)) {
      queryWrapper.likeLeft("vin", vin);
    }
    return this;
  }
  public VehicleBaseParam queryLikeLeftLicense(String vin) {
    if (!StringUtils.isEmpty(vin)) {
      queryWrapper.likeLeft("license", vin);
    }
    return this;
  }
  public VehicleBaseParam queryInVin(List<String> vin) {
    if (!CollectionUtils.isEmpty(vin)) {
      queryWrapper.in("vin", vin);
    }
    return this;
  }


  public VehicleBaseParam queryNotInVin(List<String> vin) {
    if (!CollectionUtils.isEmpty(vin)) {
      queryWrapper.notIn("vin", vin);
    }
    return this;
  }

  public VehicleBaseParam queryEqCompanyId(Long companyId) {
    if (companyId!=null) {
      queryWrapper.eq("company_id", companyId);
    }
    return this;
  }

}
